'''
分析“https://fanyi.baidu.com/”
百度翻译页面，要求用户在控制台输入需要翻译的单词给出翻译结果。
'''

import requests

word = input('请输入需要翻译的单词:')
url = 'https://fanyi.baidu.com/sug'
headers = {'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'}

params = {'kw': word}

request = requests.post(url=url,params=params,headers=headers)

result = request.json()
result['data']
lenth = len(result['data'])


for i in range(lenth):
    print(result['data'][i]['v'])

print('翻译完成')

